﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="lisadokumendid_vastus", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(LisadokumendidVastus))]
    public class LisadokumendidVastusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ILisadokumendidVastus clazz;
        
        public LisadokumendidVastusSerializer(ILisadokumendidVastus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("tulemus");
            if (clazz.Tulemus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Tulemus))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("teade");
            if (clazz.Teade!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Teade))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "tulemus")) {
                goto tulemus;
            }
            else {
                if ((Reader.LocalName == "teade")) {
                    goto teade;
                }
                else {
                    return;
                }
            }
        tulemus:
            if ((Reader.IsElementNil() == false)) {
                clazz.Tulemus = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("tulemus")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        teade:
            if ((Reader.IsElementNil() == false)) {
                clazz.Teade = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("teade")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        }
    }
}
